import java.util.Stack;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 08 - 31
 * Time: 16:01
 */
//牛客 用两个栈实现队列
public class Solution2 {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node) {
       if(stack1.isEmpty() && stack2.isEmpty()) {
           stack1.push(node);
       }else {
           while (!stack1.isEmpty()) stack2.push(stack1.pop());
           stack2.push(node);
           while (!stack2.isEmpty()) stack1.push(stack2.pop());
       }

    }

    public int pop() {
        return stack1.pop();
    }
}